home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / gtk-2.0 / gdk-pixbuf / gdk-pixdata.h < prev   
Encoding:
C/C++ Source or Header  |  2006-04-25  |  6.4 KB  |  171 lines

  1. /* GdkPixbuf library - GdkPixdata - functions for inlined pixbuf handling
  2.  * Copyright (C) 1999, 2001 Tim Janik
  3.  *
  4.  * This library is free software; you can redistribute it and/or
  5.  * modify it under the terms of the GNU Lesser General Public
  6.  * License as published by the Free Software Foundation; either
  7.  * version 2 of the License, or (at your option) any later version.
  8.  *
  9.  * This library is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.  * Lesser General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU Lesser General Public
  15.  * License along with this library; if not, write to the
  16.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17.  * Boston, MA 02111-1307, USA.
  18.  */
  19. #ifndef __GDK_PIXDATA_H__
  20. #define __GDK_PIXDATA_H__
  21.  
  22. #include        <gdk-pixbuf/gdk-pixbuf.h>
  23.  
  24. G_BEGIN_DECLS
  25.  
  26. /**
  27.  * GDK_PIXBUF_MAGIC_NUMBER:
  28.  *
  29.  * Magic number for #GdkPixdata structures.
  30.  **/
  31. #define GDK_PIXBUF_MAGIC_NUMBER (0x47646b50)    /* 'GdkP' */
  32.  
  33. /**
  34.  * GdkPixdataType:
  35.  * @GDK_PIXDATA_COLOR_TYPE_RGB:  each pixel has red, green and blue samples.
  36.  * @GDK_PIXDATA_COLOR_TYPE_RGBA: each pixel has red, green and blue samples 
  37.  *    and an alpha value.
  38.  * @GDK_PIXDATA_COLOR_TYPE_MASK: mask for the colortype flags of the enum.
  39.  * @GDK_PIXDATA_SAMPLE_WIDTH_8: each sample has 8 bits.
  40.  * @GDK_PIXDATA_SAMPLE_WIDTH_MASK: mask for the sample width flags of the enum.
  41.  * @GDK_PIXDATA_ENCODING_RAW: the pixel data is in raw form. 
  42.  * @GDK_PIXDATA_ENCODING_RLE: the pixel data is run-length encoded. Runs may 
  43.  *    be up to 127 bytes long; their length is stored in a single byte 
  44.  *    preceding the pixel data for the run. If a run is constant, its length
  45.  *    byte has the high bit set and the pixel data consists of a single pixel
  46.  *    which must be repeated. 
  47.  * @GDK_PIXDATA_ENCODING_MASK: mask for the encoding flags of the enum.
  48.  *
  49.  * An enumeration containing three sets of flags for a #GdkPixdata struct: 
  50.  * one for the used colorspace, one for the width of the samples and one 
  51.  * for the encoding of the pixel data.  
  52.  **/
  53. typedef enum
  54. {
  55.   /* colorspace + alpha */
  56.   GDK_PIXDATA_COLOR_TYPE_RGB    = 0x01,
  57.   GDK_PIXDATA_COLOR_TYPE_RGBA   = 0x02,
  58.   GDK_PIXDATA_COLOR_TYPE_MASK   = 0xff,
  59.   /* width, support 8bits only currently */
  60.   GDK_PIXDATA_SAMPLE_WIDTH_8    = 0x01 << 16,
  61.   GDK_PIXDATA_SAMPLE_WIDTH_MASK = 0x0f << 16,
  62.   /* encoding */
  63.   GDK_PIXDATA_ENCODING_RAW      = 0x01 << 24,
  64.   GDK_PIXDATA_ENCODING_RLE      = 0x02 << 24,
  65.   GDK_PIXDATA_ENCODING_MASK     = 0x0f << 24
  66. } GdkPixdataType;
  67.  
  68. /**
  69.  * GdkPixdata:
  70.  * @magic: magic number. A valid #GdkPixdata structure must have 
  71.  *    #GDK_PIXBUF_MAGIC_NUMBER here.
  72.  * @length: less than 1 to disable length checks, otherwise 
  73.  *    #GDK_PIXDATA_HEADER_LENGTH + length of @pixel_data. 
  74.  * @pixdata_type: information about colorspace, sample width and 
  75.  *    encoding, in a #GdkPixdataType. 
  76.  * @rowstride: Distance in bytes between rows.
  77.  * @width: Width of the image in pixels.
  78.  * @height: Height of the image in pixels.
  79.  * @pixel_data: @width x @height pixels, encoded according to @pixdata_type
  80.  *   and @rowstride.
  81.  *
  82.  * A #GdkPixdata contains pixbuf information in a form suitable for 
  83.  * serialization and streaming.
  84.  **/
  85. typedef struct _GdkPixdata GdkPixdata;
  86. struct _GdkPixdata
  87. {
  88.   guint32 magic;        /* GDK_PIXBUF_MAGIC_NUMBER */
  89.   gint32  length;       /* <1 to disable length checks, otherwise:
  90.              * GDK_PIXDATA_HEADER_LENGTH + pixel_data length
  91.              */
  92.   guint32 pixdata_type; /* GdkPixdataType */
  93.   guint32 rowstride;
  94.   guint32 width;
  95.   guint32 height;
  96.   guint8 *pixel_data;
  97. };
  98.  
  99. /**
  100.  * GDK_PIXDATA_HEADER_LENGTH:
  101.  *
  102.  * The length of a #GdkPixdata structure without the @pixel_data pointer.
  103.  **/
  104. #define    GDK_PIXDATA_HEADER_LENGTH    (4 + 4 + 4 + 4 + 4 + 4)
  105.  
  106. /* the returned stream is plain htonl of GdkPixdata members + pixel_data */
  107. guint8*        gdk_pixdata_serialize    (const GdkPixdata    *pixdata,
  108.                      guint            *stream_length_p);
  109. gboolean    gdk_pixdata_deserialize    (GdkPixdata        *pixdata,
  110.                      guint             stream_length,
  111.                      const guint8        *stream,
  112.                      GError               **error);
  113. gpointer    gdk_pixdata_from_pixbuf    (GdkPixdata        *pixdata,
  114.                      const GdkPixbuf    *pixbuf,
  115.                      gboolean         use_rle);
  116. GdkPixbuf*    gdk_pixbuf_from_pixdata    (const GdkPixdata    *pixdata,
  117.                      gboolean         copy_pixels,
  118.                      GError               **error);
  119. /** 
  120.  * GdkPixdataDumpType:
  121.  * @GDK_PIXDATA_DUMP_PIXDATA_STREAM: Generate pixbuf data stream (a single 
  122.  *    string containing a serialized #GdkPixdata structure in network byte 
  123.  *    order).
  124.  * @GDK_PIXDATA_DUMP_PIXDATA_STRUCT: Generate #GdkPixdata structure (needs 
  125.  *    the #GdkPixdata structure definition from gdk-pixdata.h).
  126.  * @GDK_PIXDATA_DUMP_MACROS: Generate <function>*_ROWSTRIDE</function>,     
  127.  *    <function>*_WIDTH</function>, <function>*_HEIGHT</function>,
  128.  *    <function>*_BYTES_PER_PIXEL</function> and 
  129.  *    <function>*_RLE_PIXEL_DATA</function> or <function>*_PIXEL_DATA</function>
  130.  *    macro definitions for the image.
  131.  * @GDK_PIXDATA_DUMP_GTYPES: Generate GLib data types instead of 
  132.  *    standard C data types.
  133.  * @GDK_PIXDATA_DUMP_CTYPES: Generate standard C data types instead of 
  134.  *    GLib data types.
  135.  * @GDK_PIXDATA_DUMP_STATIC: Generate static symbols.
  136.  * @GDK_PIXDATA_DUMP_CONST: Generate const symbols.
  137.  * @GDK_PIXDATA_DUMP_RLE_DECODER: Provide a <function>*_RUN_LENGTH_DECODE(image_buf, rle_data, size, bpp)</function> 
  138.  *    macro definition  to  decode  run-length encoded image data.
  139.  *  
  140.  * An enumeration which is used by gdk_pixdata_to_csource() to
  141.  * determine the form of C source to be generated. The three values
  142.  * @GDK_PIXDATA_DUMP_PIXDATA_STREAM, @GDK_PIXDATA_DUMP_PIXDATA_STRUCT
  143.  * and @GDK_PIXDATA_DUMP_MACROS are mutually exclusive, as are
  144.  * @GDK_PIXBUF_DUMP_GTYPES and @GDK_PIXBUF_DUMP_CTYPES. The remaining
  145.  * elements are optional flags that can be freely added. 
  146.  **/
  147. typedef enum
  148. {
  149.   /* type of source to save */
  150.   GDK_PIXDATA_DUMP_PIXDATA_STREAM    = 0,
  151.   GDK_PIXDATA_DUMP_PIXDATA_STRUCT    = 1,
  152.   GDK_PIXDATA_DUMP_MACROS        = 2,
  153.   /* type of variables to use */
  154.   GDK_PIXDATA_DUMP_GTYPES        = 0,
  155.   GDK_PIXDATA_DUMP_CTYPES        = 1 << 8,
  156.   GDK_PIXDATA_DUMP_STATIC        = 1 << 9,
  157.   GDK_PIXDATA_DUMP_CONST        = 1 << 10,
  158.   /* save RLE decoder macro? */
  159.   GDK_PIXDATA_DUMP_RLE_DECODER        = 1 << 16
  160. } GdkPixdataDumpType;
  161.   
  162.  
  163. GString*    gdk_pixdata_to_csource    (GdkPixdata        *pixdata,
  164.                      const gchar        *name,
  165.                      GdkPixdataDumpType     dump_type);
  166.  
  167.  
  168. G_END_DECLS
  169.  
  170. #endif /* __GDK_PIXDATA_H__ */
  171.